/*
 * collisions.h
 *
 *  Created on: Dec 17, 2011
 *      Author: armandoperico
 */

#ifndef UTIL_H_
#define UTIL_H_

#include "../entities/structs.h"
#include "../core/cell.h"


//Returns a random float from 0 to < 1
float randomFloat() {
	return (float)rand() / ((float)RAND_MAX + 1);
}
float _clip_angle(float angle_value, bool direction){
	if (direction && angle_value >= 360){
		angle_value -= 360;
		return angle_value;
	}

	if (!direction && angle_value < 0){
		angle_value += 360;
		return angle_value;
	}
	return angle_value;
}

void set_cell_x(Cell* Cell, bool direction, float v){
	float value = Cell->pos.get_x();
	if(direction){
		Cell->pos.set_x( value+=v );
	}else{
		Cell->pos.set_x( value-=v );
	}
}

void set_cell_y(Cell* Cell, bool direction, float v){
	float value = Cell->pos.get_y();
	if(direction){
		Cell->pos.set_y( value+=v );
	}else{
		Cell->pos.set_y( value-=v );
	}
}
void set_cell_z(Cell* Cell, bool direction, float v){
	float value = Cell->pos.get_z();
	if(direction){
		Cell->pos.set_z( value+=v );
	}else{
		Cell->pos.set_z( value-=v );
	}
}

#endif
